package com.web;

import java.util.HashMap;

public class CustomerManageAction extends ActionSupport {

	protected IMemberService userService;
	protected IProductService classesService;
	protected ICustomerService adminService;
	
	private Integer memberId;
	private Integer productId;
	private String name;
	private String special;
	private String product;
	private HashMap<String, Object> resultMap = new HashMap<String, Object>();
	
	public String manageCustomer() throws Exception{
		return "manageCustomer";
	}
	
	public String listProduct() throws Exception{
		ActionContext ctx = ActionContext.getContext();
		ctx.put("list", productService.listProduct());
		
		return "listPorduct";
	}
	
	public String listMember() throws Exception{
		ActionContext ctx = ActionContext.getContext();
		ctx.put("list", productService.getProduct(productId).getMember());
		return "listMember";
	}
	
	/*
	 * 设置普通客户为会员
	 * @param userId
	 */
	public String addMember() throws Exception{
		resultMap = new HashMap<String, Object>();
		Customer customer = customerService.getCustomer(customerId);
		Integer id = customerService.addCustomer(10, customer);
		if(id != null){
			resultMap.put("status", true);
			resultMap.put("msg", "设置成功");
		} else{
			resultMap.put("status", false);
			resultMap.put("msg", "设置失败");
		}
		return SUCCESS;
	}
	
	/*
	 * 删除会员
	 * @param userId
	 */
	public String delMember() throws Exception{
		resultMap = new HashMap<String, Object>();
		Customer customer = customerService.getCustomer(customerId);
		customerService.delCustomer(user.getCustomer());
		resultMap.put("status", true);
		resultMap.put("msg", "设置成功");
		return SUCCESS;
	}
	
	public void setMemberService(IMemberService memberService) {
		this.memberService = memberService;
	}
	
	public void setProductService(IProductService productService) {
		this.productService = productService;
	}

	public Integer getMemberId() {
		return memberId;
	}

	public void setMemberId(Integer memberId) {
		this.memberId = memberId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getSpecial() {
		return special;
	}

	public void setSpecial(String special) {
		this.special = special;
	}

	public String getProduct() {
		return product;
	}

	public void setProduct(String product) {
		this.product = product;
	}

	public Integer getProductId() {
		return productId;
	}

	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	public HashMap<String, Object> getResultMap() {
		return resultMap;
	}

	public void setResultMap(HashMap<String, Object> resultMap) {
		this.resultMap = resultMap;
	}

	public void setCustomerService(ICustomerService customerService) {
		this.customerService = customerService;
	}
}
